<?php
//Includes
require_once("MasterPage.php");
require_once("vcl/vcl.inc.php");
require_once("AdminLogin.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");
use_unit("rtl.inc.php");

//Class definition
class AdminDoLogin extends MasterPage
{
   public $lblInfo = null;
   public $pnLogin = null;
   public $lbPassword = null;
   public $lbUserName = null;
   public $bLogin = null;
   public $edPassword = null;
   public $edUserName = null;

   function bLoginClick($sender, $params)
   {
      global $AdminLogin;

      // Try to login using the specified username and password.
      $pid = $AdminLogin->TryLogin($this->edUserName->Text, $this->edPassword->Text);
      if($pid > 0)
      {
         $this->lbMessage->Caption = '';

         // Login succeeded, so redirect back to the main page.
         redirect("Org.php?action=view&pid=" . $pid);
      }
      else
      {
         // Login failed, so update the message.
         $this->lbMessage->Caption = 'Failed to login. Please check that you are using the correct username and password.';
      }
   }
}

global $application;

global $AdminDoLogin;

//Creates the form
$AdminDoLogin = new AdminDoLogin($application);

//Read from resource file
$AdminDoLogin->loadResource(__FILE__);

//Shows the form
$AdminDoLogin->show();

?>